using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using emp.SqlServerDAL;

namespace emp.Ext
{
    public class ExtandForSql
    {
        public DataTable GetReportData(string sql)
        {
            SqlDataAdapter da = new SqlDataAdapter();
            DataTable table = new DataTable();
            using (SqlConnection conn = new SqlConnection(SQLHelper.CONN_STRING_DTC_INV))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);
                da.SelectCommand = cmd;
                da.Fill(table);
            }
            return table;
        }

        public int RunSql(string sql)
        {
            int iReturnValue = 0;
            using (SqlConnection conn = new SqlConnection(SQLHelper.CONN_STRING_DTC_INV))
            {
                conn.Open();
                try
                {
                    iReturnValue = SQLHelper.ExecuteNonQuery(conn, CommandType.Text, sql, null);
                }
                catch(Exception err)
                {
                    iReturnValue = -1;                    
                }

                return iReturnValue;
            }
        }
    }
}
